package com.zrrd.fuxi._02_set;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo03
 * @description
 * @create 2023/11/19 16:11
 */
public class Demo03 {
    @Test
    public void personTest(){
        List<Person> list=new ArrayList<>();

        list.add(new Person(5,"张三"));
        list.add(new Person(1,"李四"));
        list.add(new Person(6,"王五"));
        list.add(new Person(8,"赵六"));
        list.add(new Person(2,"张111三"));

        //自定义排序--临时排序
        list.sort((o1, o2) -> {
            if (o1.getId()==o2.getId()){
                return 0;
            }else if(o1.getId()>o2.getId()){
                return 1;
            }
            return -1;
        });


        list.forEach(System.out::println);

    }


}
